home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group02b.txt / 000089_icon-group-sender_Thu Oct 24 12:49:33 2002.msg < prev    next >
Internet Message Format  |  2003-01-02  |  1KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id g9OJnNU02327
  4.     for icon-group-addresses; Thu, 24 Oct 2002 12:49:23 -0700 (MST)
  5. Message-Id: <200210241949.g9OJnNU02327@baskerville.CS.Arizona.EDU>
  6. From: "Paul W. Abrahams" <abrahams@acm.org>
  7. To: icon-group@cs.arizona.edu
  8. Subject: move_corresponding -- whoops!!!
  9. Date: Thu, 24 Oct 2002 12:36:01 -0400
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11. Status: RO
  12.  
  13. Seems that I reversed the direction of the critical assignment expression, so 
  14. that the assignment is from s2 to s1 rather than s1 to s2 as it should be. 
  15. The correct procedure is:
  16.  
  17.  
  18.  
  19. procedure move_corresponding(s1,s2)
  20.  
  21. # move_corresponding moves correspondingly-named fields from the
  22. # record parameter s1 to the record parameter s2.  Fields whose
  23. # names are not common are not affected.  The ordering of the field
  24. # names is irrelevant.
  25.  
  26. local names1,names2,n,i
  27.  
  28. # Generate the set of common names
  29.  
  30. names1:=set()
  31. every i := 1 to *s1 do
  32.          insert(names1,name(s1[i]) ? (tab(upto('.')),=".",tab(0)))
  33. every write(!names1)
  34. names2:=set()
  35. every i := 1 to *s2 do
  36.          insert(names2,name(s2[i]) ? (tab(upto('.')),=".",tab(0)))
  37.  
  38. # Now copy the components with shared names
  39.  
  40. every n := !(names1**names2) do
  41.         s2[n] := s1[n]
  42. end
  43.